home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games: Greatest Hits 1996
/
Amiga Games: Greatest Hits 1996.iso
/
archive
/
userbox
/
publicdomain
/
megabook.lha
/
MegaBook
/
Rexx
/
LoadOld.mbrx
< prev
next >
Wrap
Text File
|
1996-07-23
|
2KB
|
103 lines
/*
** LoadOld.mbrx Version 1.1
** By Tom Bampton
**
** © 1996 Eden Software
**
** Loads an old MegaBook v2.0/2.1 file.
** If you wish to convert files, its probably better to use the FileConvert
** programs instead of this script. This is just an example! Interestingly
** enuff, this is an almost direct conversion of the C code used in
** MegaBook v2.0/2.1 to load files.
**
** If you run this from the CLI with RX then you can give it a filename
** argument. If an argument isn't found, you'll get a file requester.
**
** From MegaBook v3.1, this script may also be used from the menu option
** 'Load Old...'
*/
/* The path to MegaBook in case it isn't running */
MegaBookPath = 'MegaBook3:MegaBook'
/* To get newlines in requesters */
LF = '0a'x
parse arg File
/* Check if MegaBook is running, if not, run it */
if ~show('P', 'MEGABOOK.01') then do
address command
'run >nil: ' MegaBookPath
/* Wait for the ARexx port */
do 5 while ~show('P', 'MEGABOOK.01')
'sys:rexxc/waitforport MEGABOOK.01'
end
end
address 'MEGABOOK.01'
options results
/* If no command line arguments, open the file requester */
if File = '' then do
SelectFile 'Select MegaBook v2.0 file ...'
File = result
if RC = 5 then exit
end
if Open(fp, File, 'r') then do
head = readln(fp)
/* Check the header for the filetype */
if head ~= 'PB20' then do
Request 'Not a MegaBook 2.0/2.1 file' GADS 'Sorry'
call Close(fp)
exit
end
/* Remove the current database */
GetNumRecs
if rc ~= 0 then do
Request 'You will lose your current database'LF'Are you sure ?' Gads '_Yes|_No'
if RC = 1 then New No_Confirm
else exit
end
do while ~eof(fp)
/* Read name, fone number and fax numeber */
name = readln(fp)
if(eof(fp)) then break
fone = readln(fp)
fax = readln(fp)
/* Add an entry */
Add_Entry
/* Put in the name */
Put_Entry 1 name
/* Blank out the unneeded fields */
Put_Entry 2 ''
Put_Entry 3 ''
Put_Entry 4 ''
Put_Entry 5 ''
Put_Entry 6 ''
/* And store the fone number and fax */
Put_Entry 7 fone
Put_Entry 8 fax
Set_Type 1 1
Set_Type 2 2
end
call Close(fp)
end
else do
/* We couldn't open the requsted file, display an error */
Request 'Cant find file' GADS 'Sorry'
end